<template>
  <!-- 用户基本信息 -->
  <div class="baseInformation comflex item-center">
    <div class="userInfo comflex item-center">
      <div class="userPhoto">
        <i class="el-icon-user"></i>
      </div>
      <div class="userName">
        <div>{{ userInfo.staffName }} 你好！</div>
        <div class="ID">ID：{{ userInfo.account }} </div>
      </div>
    </div>
    <div class="breedlnfo">
      <div class="breedItem comflex">
        <div class="label">当前养殖品种：</div>
        <div class="breedItem-text comflex item-center">
          <div v-if="!breedInfo.varietyNameList || breedInfo.varietyNameList.length == 0">暂无数据！</div>
          <template v-else>
            <div v-for="(item, index) in breedInfo.varietyNameList" :key="index" v-show="index <= 9 || isShowAllVariety">
              <span>{{ item }}</span>
            </div>
          </template>
          <div class="btn" v-show="breedInfo.varietyNameList && breedInfo.varietyNameList.length > 10"
            @click="isShowAllVariety = !isShowAllVariety">
            {{ isShowAllVariety ? '收起' : '查看更多' }}</div>
        </div>
      </div>
      <div class="breedItem comflex">
        <div class="label">当前养殖批次：</div>
        <div class="breedItem-text comflex item-center">
          <div v-if="!breedInfo.varietyNameList || breedInfo.varietyNameList.length == 0">暂无数据！</div>
          <template v-else>
            <div v-for="(item, index) in breedInfo.batchNameList" :key="index" v-show="index <= 9 || isShowAllBatch">
              <span>{{
                item }}</span>
            </div>
          </template>
          <div class="btn" v-show="breedInfo.batchNameList && breedInfo.batchNameList.length > 10"
            @click="isShowAllBatch = !isShowAllBatch">
            {{ isShowAllBatch ? '收起' : '查看更多' }}</div>
        </div>
      </div>
      <div class="breedItem comflex">
        <div class="label">当前养殖鱼塘：</div>
        <div class="breedItem-text comflex item-center">
          <div v-if="!breedInfo.varietyNameList || breedInfo.varietyNameList.length == 0">暂无数据！</div>
          <template v-else>
            <div v-for="(item, index) in breedInfo.pondNameList" :key="index" v-show="index < 9 || isShowAllPond"><span>{{
              item }}</span></div>
          </template>
          <div class="btn" v-show="breedInfo.pondNameList && breedInfo.pondNameList.length > 10"
            @click="isShowAllPond = !isShowAllPond">{{
              isShowAllPond ? '收起'
              : '查看更多' }}</div>
        </div>
      </div>
    </div>
    <div class="useRatio">
      <div :style="{ width: '100%' }">养殖总面积：<span :style="{ color: '#58d14b', fontSize: '24px' }">
          {{ breedInfo.area + breedInfo.areaUnit }}</span>
      </div>
      <div :style="{ width: '100%' }">鱼塘利用率：<span :style="{ color: '#37d3c5', fontSize: '24px' }">
          {{ breedInfo.useRatio }}</span>
      </div>
    </div>
  </div>
</template>

<script>

import { mymixin } from "@/utils/mixins";
import BatchMangeApi from "@/api/batch-mange"
export default {
  name: "baseformation",
  props: {},
  mixins: [mymixin],
  data() {
    return {
      breedInfo: {},
      userInfo: {},
      isShowAllBatch: false,
      isShowAllPond: false,
      isShowAllVariety: false,
    }
  },
  watch: {},
  created() { },
  mounted() {
    this.init()
  },
  methods: {
    init() {
      this.getBreedInfo()
      this.userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
      this.userInfo['staffName'] = sessionStorage.getItem('staffName')
    },
    getBreedInfo() {
      BatchMangeApi.getBreedInfo({}).then((res) => {
        if (res.success && res.data) {
          this.breedInfo = res.data
        } else {
          this.breedInfo = {}
        }
      })
    }
  }
};
</script>
<style scoped lang="scss">
.comflex {
  display: flex;
  justify-content: flex-start;
}

.item-center {
  align-items: center;
}

.baseInformation {
  width: 100%;
  padding: 20px;
  margin: 15px 0;
  box-shadow: 1px 1px 50px 10px #eaeaea;
  border-radius: 10px;
  border: 1px solid #e9e9e9;
  background-image: linear-gradient(45deg, #ffffff, #f8f8f8);

  .userPhoto {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #d5d5d5;
    font-size: 18px;
    color: #ffffff;
    text-align: center;
    line-height: 50px;

    img {
      width: 100%;
      height: 100%;
    }
  }

  .userInfo {
    width: 20%;
    box-sizing: border-box;

    .userName {
      margin: 0 20px;
      font-size: 16px;
      color: #333;
      line-height: 24px;

      .ID {
        padding: 0;
        color: #009dff;
        font-size: 14px;
        line-height: 24px;
      }
    }
  }

  .breedlnfo {
    width: 60%;
    box-sizing: border-box;
    font-size: 16px;
    line-height: 36px;

    .breedItem {
      width: 100%;

      .label {
        width: 130px;
        text-align: right;
        color: #909090;
        font-weight: bold;
      }

      .breedItem-text {
        width: calc(100% - 130px);
        flex-flow: row wrap;
        color: #333;
        font-size: 14px;

        span {
          padding: 5px 30px;
          margin-right: 5px;
          background: #d7d7d7;
          border-radius: 6px 0 0 0;
          color: #fff;
          cursor: pointer;
        }
      }
    }
  }

  .useRatio {
    width: 20%;
    height: 120px;
    color: #333;
    font-size: 16px;
    font-weight: bold;
    text-align: right;
    display: flex;
    flex-flow: row wrap;
    align-content: space-around;
  }
}

.v-enter,
.v-leave-to {
  opacity: 0;
  transform: translateX(100px);
}

.v-enter-active,
.v-leave-active {
  transition: all 1s ease;
  /*所有属性 1s 过渡效果*/
}

.v-enter-to,
.v-leave {
  opacity: 0.5;
  transform: translateX((40px));
}

.btn {
  cursor: pointer;
  color: #009dff;
}</style>
